package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsDictDataParam;
import com.macro.mall.dto.BmsExhibitionsActivitiesParam;
import com.macro.mall.dto.BmsGuidePointParam;
import com.macro.mall.model.BmsDictData;
import com.macro.mall.model.BmsExhibitionsActivities;
import com.macro.mall.model.BmsGuidePoint;
import com.macro.mall.service.BmsDictDataService;
import com.macro.mall.service.BmsExhibitionsActivitiesService;
import com.macro.mall.service.BmsGuidePointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 导览点位ontroller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "BmsGuidePointController")
@Tag(name = "BmsGuidePointController", description = "导览点位管理")
@RequestMapping("/guidePoint")
public class BmsGuidePointController {
    @Autowired
    private BmsGuidePointService bmsGuidePointService;

    @Autowired
    private BmsDictDataService bmsDictDataService;
    @ApiOperation("添加导览点位")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> create(@RequestBody BmsGuidePointParam bmsGuidePointParam) {
        int count = bmsGuidePointService.create(bmsGuidePointParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }


    @ApiOperation("修改导览点位")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> update(@RequestBody BmsGuidePointParam bmsGuidePointParam) {
        int count = bmsGuidePointService.update(bmsGuidePointParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
    @ApiOperation("分页查询导览点位")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsGuidePoint>> getList(@RequestBody BmsGuidePointParam bmsGuidePointParam) {
        List<BmsGuidePoint> BmsGuidePointList = bmsGuidePointService.getList(bmsGuidePointParam);
        return CommonResult.success(CommonPage.restPage(BmsGuidePointList));
    }
//
    @ApiOperation("根据id获取导览点位信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsGuidePoint> getItem(@PathVariable Long id) {
        BmsGuidePoint bmsGuidePoint = bmsGuidePointService.getDetail(id);
        return CommonResult.success(bmsGuidePoint);
    }
//
    @ApiOperation("删除导览点位")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> delete(@RequestBody List<Long> ids) {
        int count = bmsGuidePointService.delete(ids);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }



    @ApiOperation("查询字典表值")
    @RequestMapping(value = "/dataList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsDictData>> selectList(@RequestBody BmsDictDataParam bmsDictDataParam) {
        List<BmsDictData> bmsDictDataList = bmsDictDataService.selectList(bmsDictDataParam);
        return CommonResult.success(CommonPage.restPage(bmsDictDataList));
    }

}
